package com.tool.shardingjdbc.core.service.impl;

import com.tool.shardingjdbc.core.dao.TestDao;
import com.tool.shardingjdbc.core.model.Test;
import com.tool.shardingjdbc.core.service.TestService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @description:
 * @author: weirui
 * @create: 2020-07-23 17:16
 **/
@Service
public class TestServiceImpl implements TestService {

    @Autowired
    private TestDao testDao;

    @Transactional(rollbackFor = Exception.class)
    public void testInsert(List<Test> list) {
        for (Test test : list) {
            testDao.insertSelective(test);
        }
    }

    @Transactional(rollbackFor = Exception.class)
    public int update(List<Integer> ids) {
        return testDao.updateByPrimaryKey(new Test());
    }
}
